import cv2
import numpy as np

def empty(obj):
    pass
cv2.namedWindow("TrackBars")
cv2.resizeWindow("TrackBars",640,240)
cv2.createTrackbar("Hue Min","TrackBars",0,180,empty)
cv2.createTrackbar("Hue Max","TrackBars",19,180,empty)
cv2.createTrackbar("Sea min","TrackBars",134,255,empty)
cv2.createTrackbar("Sat Max","TrackBars",255,255,empty)
cv2.createTrackbar("Val min","TrackBars",160,255,empty)
cv2.createTrackbar("Val Max","TrackBars",255,255,empty)

while True:
    h_min=cv2.createTrackbar("Hue Min", "TrackBars", 0, 180, empty)
    h_max=cv2.createTrackbar("Hue Max", "TrackBars", 19, 180, empty)
    S_min=cv2.createTrackbar("Sea min", "TrackBars", 134, 255, empty)
    S_max=cv2.createTrackbar("Sat Max", "TrackBars", 255, 255, empty)
    V_min=cv2.createTrackbar("Val min", "TrackBars", 160, 255, empty)
    V_max=cv2.createTrackbar("Val Max", "TrackBars", 255, 255, empty)
    lower=np.array([h_min],[S_min],[V_min])
    upper=np.array([h_max],[S_max],[V_max])
    mask=cv2.inRange(imgHsv,lower,upper)
    cv2.imshow("Mask",mask)
    imgResult=cv2.bitwise_and(img,img,mask=mask)
    cv2.imshow("Result",imgResult)
    if cv2.waitKey(1)==ord('q'):
        break
cv2.destroyAllWindows()